//域名地址
var com_url = '10.50.90.14';

$(document).keydown(function(event) {
	if(event.keyCode == 13) {
		$(".keydown_search").click();
	}
});
 
function unique1(arr) {
	var hash = [];
	for(var i = 0; i < arr.length; i++) {
		if(hash.indexOf(arr[i]) == -1) {
			hash.push(arr[i]);
		}
	}
	return hash;
}

$(".layui-tab-title li").click(function() {
	var picTabNum = $(this).index();
	localStorage.setItem("picTabNum", picTabNum); //放入session
});
var getPicTabNum = localStorage.getItem("picTabNum");
var sesstion_Herf_id = localStorage.getItem("Herf_id");
$(".layui-tab-title li").eq(getPicTabNum).addClass("layui-this").siblings().removeClass("layui-this");
//if(getPicTabNum){
//			$('.layui-tab-title li').eq(getPicTabNum).trigger('click')
////			$(".layui-tab-content>div").eq(getPicTabNum).addClass("layui-show").siblings().removeClass("layui-show");
//	}
//清楚session
function deleteItem() {
	localStorage.setItem("picTabNum", '0'); //放入session
	localStorage.setItem("select_val1", '');
	localStorage.setItem("select_value_name", '');
}

//选择负责人
layui.use(['table', 'form', 'jquery', 'layer'], function() {
	var $ = layui.$ //重点处
		,
		layer = layui.layer;
	var form = layui.form;
	var table = layui.table;
	table.render({
		elem: '#LAY_table_users',
		url: "http://" + com_url + "//admin/down",
		response: {
			dataName: 'data.principal',
			statusCode: 200
		},
		cols: [
			[{
				field: 'sex',
				width: '20%',
				title: '标记',
				templet: "#radioTpl",
				unresize: true,
				event: 'setSign',
			}, {
				field: 'name',
				width: '20%',
				title: '员工',
			}, {
				field: 'position_name',
				width: '30%',
				title: '部门',
			}, {
				field: 'position',
				width: '25%',
				title: '岗位',
			}]
		],
		id: 'admin_table',
		done: function(res, count, curr) { //回调函数
			departent_name = res.data.parent;
			var target = $("#select_name3");
			target.find('option').remove().end();
			target.append($("<option></option>").attr("value", "").text('请选择'));
			$.each(departent_name, function(key, role) { //遍历  
				target.append($("<option></option>").attr("value", role).text(role));
			});
			form.render('select')
		}
	});
	//监听下拉框
	form.on('select(select_value2)', function(data) {
		var select_val = data.value;
		table.reload('admin_table', {
			where: {
				depars: select_val,
			}
		});
	});
});
//请求头
var cookie_val_fun = function(request) {
	request.setRequestHeader("ApiAuth", cookie_val);
}